package com.ffox.controller;

import com.ffox.entity.Teachers;
import com.ffox.result.Result;
import com.ffox.service.SchoolTeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/schoolTeacher")
public class SchoolTeacherController {
    /*1、添加教师
    * 2、编辑教师
    * 3、删除教师
    * 4、查看教师*/
    @Autowired
    private SchoolTeacherService schoolTeacherService;

    @PostMapping("/addTeacher")
    public Result<Integer> addTeacher(@RequestBody Map<String, Object> params) {
        return Result.success("添加成功",schoolTeacherService.addTeacher(params));
    }
    @PostMapping("/updateTeacher")
    public Result<Integer> updateTeacher(@RequestParam String teacherId, @RequestBody Map<String, Object> params) {
        // 注意：params是复杂类型，也建议用@RequestBody
        System.out.println("进入update");
        return Result.success("更新成功",schoolTeacherService.updateTeacher(teacherId, params));
    }

    // deleteTeacher同理
    @PostMapping("/deleteTeacher")
    public Result<Integer> deleteTeacher(@RequestParam String teacherId) { // 改为String类型
        return Result.success("删除成功",schoolTeacherService.deleteTeacher(teacherId));
    }
    @PostMapping("/getAllTeacherBySchoolId")
    public Result<List<Teachers>> getAllTeacherBySchoolId(@RequestParam String schoolNum) {
        System.out.println(schoolNum+"获取了全部教师");
        return Result.success("获取成功",schoolTeacherService.getALlTeacherBySchoolId(schoolNum));
    }

}
